#include<stdio.h>

int insert_sort(int arr[], int n);
int main(int argc, char *argv[])
{
	int arr[10] = {5,6,7,9,2,1,44,55,22,31};
	insert_sort(arr, 10);
	for(int i = 0; i < 10; i++){
		printf("%d ", arr[i]);
	}
	return 0;
}

int insert_sort(int arr[], int n){
	int i, j;
	int tem;

	for(i = 1; i < n; i++){
		tem = arr[i];
		for(j = i-1; j >= 0;j--){ //找到第一个比arr[i]小的下标
			if(tem < arr[j]){
				arr[j + 1] = arr[j];
			}else{
				break;
			}
		}
		arr[j+1] = tem;
	}
	return 0;
}
